package miracle.joker.design.mediator;

public class MediatorDemo {

    public static void main(String[] args) {
        // 创建聊天室对象
        ChatRoom chatRoom = new ChatRoom();

        // 创建用户并注册到聊天室中
        User u1 = new User("Alice", chatRoom);
        chatRoom.registerUser(u1);

        User u2 = new User("Bob", chatRoom);
        chatRoom.registerUser(u2);

        User u3 = new User("Charlie", chatRoom);
        chatRoom.registerUser(u3);

        // 用户发送消息
        u1.sendMessage("Hello, I'm Alice");
        u2.sendMessage("Hi, I'm Bob");
        u3.sendMessage("Nice to meet you, I'm Charlie");
    }
}
